<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <style>
        .red {
            color: red;
            font-size: 20px;
        }
    </style>
</head>

<body>
    <div class="red">asdfasdffsf</div>

    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script>
        // 获取字体大小 
        var size = $('.red').css('font-size');
        console.log('font-size', size);

        // 设置样式:背景变灰色,添加边框,可以连着写
        $('.red').css('background-color', 'gray');
        $('.red').css('border', '2px solid blue');

        // 链式调用
        setTimeout(function() {
            $('.red').css('background-color', 'green').css('border', '2px solid red').css('font-size', '26px');
        }, 2000)
    </script>
</body>

</html>